package com.ysj.demo.accompanynetwork;

import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * Created by 80530 on 2018/8/5.
 */

public class ApiServiceUntil {
    private static volatile ApiServiceUntil apiServiceUntil = null;
    private Retrofit retrofit;
    private ApiService mApi;
    private PostService postService;
    private BounsPointsService bounsPointsService;


    private ApiServiceUntil(){
//        apiServiceUntil
        if (retrofit == null) {
            retrofit = new Retrofit.Builder()
                    //使用自定义的mGsonConverterFactory
                    .addConverterFactory(GsonConverterFactory.create())
                    .baseUrl("http://47.100.22.85:8080/")
                    .build();
        }
        if (mApi == null) {
            mApi = retrofit.create(ApiService.class);
            postService = retrofit.create(PostService.class);
            bounsPointsService = retrofit.create(BounsPointsService.class);
        }
       // return mApi;
    }

    public static ApiServiceUntil getInstance(){
        if (apiServiceUntil == null){
            synchronized (ApiServiceUntil.class){
                if (apiServiceUntil == null){
                    synchronized (ApiServiceUntil.class){
                        apiServiceUntil = new ApiServiceUntil();
                    }
                }
            }
        }
        return apiServiceUntil;
    }

    public Retrofit getRetrofit() {
        return retrofit;
    }

    public void setRetrofit(Retrofit retrofit) {
        this.retrofit = retrofit;
    }

    public ApiService getmApi() {
        return mApi;
    }

    public void setmApi(ApiService mApi) {
        this.mApi = mApi;
    }

    public PostService getPostService() {
        return postService;
    }

    public void setPostService(PostService postService) {
        this.postService = postService;
    }

    public BounsPointsService getBounsPointsService() {
        return bounsPointsService;
    }

    public void setBounsPointsService(BounsPointsService bounsPointsService) {
        this.bounsPointsService = bounsPointsService;
    }
}
